//++++++ Define Message Bit Number +++++++++++++++            
enum BWRType{INITRNG=0x0,PEDRNG=0x1,INCBWR=0x2,AGTBWR=0x3,POLLONE=0x4,CONTENTION=0x5};
enum CID_Type
{
	IRNG_CID   =0x0,
	BASIC_CID    =0x1,
	PRIMARY_CID  =0x2,
	TRANSPORT_UGS_CID=0x3,
	TRANSPORT_RTPS_CID=0x4,
	TRANSPORT_NRTPS_CID=0x5,
	TRANSPORT_BS_CID=0x6,
	BROADCAST_CID=0x7,
	PADDING_CID =0x8
};
enum FC{FIRST=2,CONTINUE=3,UNFRAGMENT=0,LAST=1};
enum STATUS{FIRSTQ=2,CONTINUEQ=3,UNFRAGMENTQ=0,LASTQ=1,COMPLETED=4 ,BROKEN=5};
enum Signaling_Header_Type
{
	BR_Inc    = 0x0
   ,BR_Agr    = 0x1
   ,PHY_CR    = 0x2
   ,BR_UTPR   = 0x3
   ,BWQ_CINR  = 0x4
   ,BR_USLC   = 0x5
   ,SN_Report = 0x6
   ,CQICH     = 0x7
};
//FCH MESSAGE FORMAT    
#define L_UB_SBCH     6 
#define L_RP_CD_IND   2 
#define L_CD_IND      3 
#define L_DMP_LEN     8 
//DCD MESSAGE FORMAT  (bits)   
#define L_MMTYPE_1    8 
#define L_CCC         8 
//DCD TLV MESSAGE FORMAT   (bytes)                     
#define L_01001_DBP         1 
#define L_01002_BSEIRP      2 
#define L_01006_CH_NUM      1 
#define L_01007_TTG         1 
#define L_01008_RTG         1 
#define L_01009_EIRxP       2 
#define L_01010_CWFNUM      3 
#define L_01012_FREQ        4 
#define L_01013_BSID        6 
#define L_01017_HAD         1 
#define L_01148_MACVER      1 
#define L_01020_MAX_RETRAN  1 
#define L_01021_RSSI_CINR   1 

//RNG RSP TLV MESSAGE FORMAT
#define L_05001_TA     4 //timing adjust
#define L_05002_PLA    1 //power level adjust
#define L_05003_OFA    4 //offset frequency adjust
#define L_05004_RS     1 //rnging status
#define L_05005_DFO    4 //downlink frequency override
#define L_05006_UCIDO  1 //uplink channel id override
#define L_05007_DOBP   2 //downlink operational burst profile
#define L_05008_MACADR 6 //ss mac address
#define L_05009_BCID   2 //basic cid
#define L_05010_PMCID  2 //primary management cid
#define L_05011_ABP    1 //aas broadcast permission 
#define L_05012_FN     3 //frame number
#define L_05013_IRON   1 //initial ranging opportunity number
#define L_05150_RCA    4 //ranging code attributes
#define L_05017_SLP    1 //service level prediction
#define L_05018_GSCN   4 //global service class name
#define L_05020_RRF    1 //resource retain flag
#define L_05021_HPO    2 //ho process optimization

////RNG REQ TLV MESSAGE FORMAT
#define L_04001_RDBP  1 //requested downlink burst profile
#define L_04002_SMA   6 //ss mac address
#define L_04003_RA    1 //ranging anomalies
#define L_04004_ABC   1 //aas broadcast capability
#define L_04005_SBID  6 //serving BS ID
#define L_04006_RPI   1 //ranging purpose indication
#define L_04007_HOID  1 //HO ID
#define L_04009_PCID  6 //paging controller ID
#define L_04010_MHST  2 //mac hash skip threshold
#define L_04008_PDI   1 //power down indicator
#define L_04011_EAT   1 //enabled action triggered
#define L_04012_RDRCL 1 //requested downlink repetiotion coding level

//UCD MESSAGE FORMAT (bits)
#define L_MMTYPE_0    8 
#define L_RANGBOS     8
#define L_RANGBOE     8
#define L_REQBOS      8
#define L_REQBOE      8

//UCD TLV MESSAGE FORMAT  (bytes)
#define L_SRCG_TLV155    1  //155
#define L_PB_TLV156      1  //156
#define L_UASB_TLV18     9  //18
#define L_MR_TLV174      1  //174
#define L_UPO_TLV190     1  //
#define L_DPO_TLV191     1
#define L_MINLPO_TLV192  1
#define L_MAXLPO_TLV193  1
#define L_IRI_TLV195     1
#define L_IRANGBS_TLV198 1
#define L_IRANGBE_TLV199 1
#define L_BWREQBS_TLV200 1
#define L_BWREQBE_TLV201 1
                        
//DLMAP MESSAGE FORMAT        (bits)
#define L_MMTYPE_2              8   
#define L_FRAME_DURATION_CODE   8   
#define L_FRAME_NUMBER          24  
#define L_DCD_COUNT             8   
#define L_BSID                  48  
#define L_NO_OFDMASYMBOLS       8   
#define L_PADDING               4   
//OFDMA DLMAP_IE FORMAT       (bits)       
#define L_DIUC                  4   
#define L_N_CID                 8   
#define L_CID                   16  
#define L_OFDMA_SYMBOL_OFFSET   8   
#define L_SUBCHANNEL_OFFSET_1   6   
#define L_BOOSTING_1            3   
#define L_NO_OFDMASYMBOLS_1     7   
#define L_NO_SUBCHANNELS_1      6 
#define L_REPETITION_CODING_IND 2 

//ULMAP MESSAGE FORMAT

#define L_MMTYPE_3        8   
#define L_UCD_COUNT       8   
#define L_START_TIME      32  
#define L_No_OFDMA_SYMB   8
//
#define L_DURATION_DIUC 10
#define L_REP_CODE_IND  2
//CDMA Bandwidth Request, CDMA Ranging DIUC_12

#define L_OFDMA_SYMBOL_OFFSET_U 8   
#define L_SUBCHANNEL_OFFSET_U   7   
#define L_NO_OFDMASYMBOLS_U     7   
#define L_NO_SUBCHANNELS_U      7   
#define L_RNG_METHOD            2 
#define L_DEDICATE_RNG_IND      1

//CDMA Allocation IE format DIUC_14
#define L_DURATION_CDMA  6
#define L_UIUC           4
#define L_REP_CODE_IND   2
#define L_FNUMINDEX      4
#define L_RNG_CODE       8
#define L_RNG_SYB        8
#define L_RNG_SBC        7
#define L_BW_REQ_MAND    1



//Packing SubHeader FORMAT     (bits)   
#define L_PSH_FC                2 
#define L_PSH_BSN               11
#define L_PSH_FSN_0             11
#define L_PSH_FSN_1             3 
#define L_PSH_LENGTH            11
//Fragment SubHeader Format    (bits)   
#define L_FSH_FC                2 
#define L_FSH_BSN               11
#define L_FSH_FSN_0             11
#define L_FSH_FSN_1             3   
#define L_FSH_LENGTH            11  
//Generic MacHeader Format     (bits)   
#define L_GHeader_HT            1 
#define L_GHeader_EC            1 
#define L_GHeader_Type          6 
#define L_GHeader_ESF           1 
#define L_GHeader_CI            1 
#define L_GHeader_EKS           2 
#define L_GHeader_LEN           11
#define L_GHeader_CID           16
#define L_GHeader_HCS           8 
#define L_BYTE                  8 
                                  
//++++++++++ Define Some Marco ++++++++++++++                 
#define BSWAP(a) (a = ((a>>24)&0xff) | (((a>>16)&0xff)<<8) | \
                      (((a>>8)&0xff)<<16) | ((a&0xff)<<24))   
                                                              
//++++++++++ Define Message Byte Number ++++++++++++++        
#define L_CRC 4                                               
#define L_MACHEADER 6    

#define TAG_INITRNGCODE 0
#define TAG_PERRNGCODE  1
#define TAG_BWR         2
#define TAG_CDMAIE      3
#define TAG_RNGRSP_C    5
#define TAG_RNGRSP_S1   6
#define TAG_RNGRSP_S2   7

#define TYPE_FCH      256
#define TYPE_UCD      0
#define TYPE_DCD      1
#define TYPE_DLMAP    2
#define TYPE_ULMAP    3
#define TYPE_RNGREQ   4
#define TYPE_RNGRSP   5
#define TYPE_REGREQ   6
#define TYPE_REGRSP   7
#define TYPE_BWRREQ   254
#define TYPE_CDMACODE 255

#define TIMER_T9 0

#define TIMEOUT_T9 1000